

#import "FAMMinePersonalDataViewController.h"

@interface FAMMinePersonalDataViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *FAMScrollView;
@property (weak, nonatomic) IBOutlet UILabel *FAMGenderLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMAgeLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMHeightLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMLastWeightLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMTargetWeightLabel;
@property (weak, nonatomic) IBOutlet UILabel *FAMTargetLabel;


@end

@implementation FAMMinePersonalDataViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self FAM_loadData];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self FAM_showUi];
}
- (void)FAM_showUi{
    self.title = @"Personal data";
    self.FAMScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
- (void)FAM_loadData{
    if ([[FAMUserManger shareInstance].userModel.gender isEqualToString:@"1"]) {
        self.FAMGenderLabel.text = @"Male";
    }else{
        self.FAMGenderLabel.text = @"Female";
    }
    self.FAMAgeLabel.text = [FAMUserManger shareInstance].userModel.age;
    self.FAMHeightLabel.text = [NSString stringWithFormat:@"%@cm",[FAMUserManger shareInstance].userModel.height];
    self.FAMLastWeightLabel.text = [NSString stringWithFormat:@"%@kg",((FAMWeightsModel *)[FAMUserManger shareInstance].userModel.weights.lastObject).weight];
    
    self.FAMTargetWeightLabel.text = [FAMUserManger shareInstance].userModel.target_weight == nil ? @"0kg" : [NSString stringWithFormat:@"%@kg",[FAMUserManger shareInstance].userModel.target_weight];
    
    if ([[FAMUserManger shareInstance].userModel.target_type isEqualToString:@"1"]) {
        self.FAMTargetLabel.text = @"Lose weight";
    }else if ([[FAMUserManger shareInstance].userModel.target_type isEqualToString:@"2"]){
        self.FAMTargetLabel.text = @"Gain weight";
    }else{
        self.FAMTargetLabel.text = @"Maintain weight";
    }
}
- (IBAction)FAM_genderTapClick:(UITapGestureRecognizer *)sender {
    [self.navigationController pushViewController:[FAMMineGenderViewController new] animated:YES];
}

- (IBAction)FAM_ageTapClick:(UITapGestureRecognizer *)sender {
    [self.navigationController pushViewController:[FAMMineAgeViewController new] animated:YES];
}
- (IBAction)FAM_heightTapClick:(UITapGestureRecognizer *)sender {
    [self.navigationController pushViewController:[FAMMineHeightViewController new] animated:YES];
}

- (IBAction)FAM_lsatWeightTapClick:(UITapGestureRecognizer *)sender {
    FAMMineLastAndTargetWeightViewController * vc = [FAMMineLastAndTargetWeightViewController new];
    vc.FAMIsTarget = NO;
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)FAM_targetWeightTapClick:(UITapGestureRecognizer *)sender {
    FAMMineLastAndTargetWeightViewController * vc = [FAMMineLastAndTargetWeightViewController new];
    vc.FAMIsTarget = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)FAM_targetTapClick:(UITapGestureRecognizer *)sender {
    [self.navigationController pushViewController:[FAMMinGoalViewController new] animated:YES];
}

@end
